<?php

use think\facade\Route;

/* 用户课程相关 */
Route::group('course', function () {
    Route::put('favorite', '@setFavorite');
    Route::get('schedule/daily', '@getDailySchedule');
    Route::get('schedule/period', '@getPeriodSchedule');
})->prefix('\app\user\service\user\Course');

/* 用户卡券 */
Route::group('coupon', function () {
    Route::get('<type>$', '@list');
    Route::post('exchange$', '@exchange');
})->prefix('\app\user\service\user\Coupon');

/* 用户购物车 */
Route::group('cart', function () {
    Route::get('num$', '@getNum');            // 购物车数量
    Route::get('$', '@cartFetch');        // 购物车页面
    Route::post('$', '@cartAdd');        // 添加到购物车
    Route::delete('$', '@cartDelete');     // 删除购物车商品
})->prefix('\app\user\service\user\Cart');

/** 用户课程管理 */
Route::group('admin/student', function () {
    Route::get('<userId>/course/list', '@studentCourse')->pattern(['userId' => '\d+']);
})->prefix('\app\user\service\user\admin\Course')->middleware(['adminRoute']);

/** 用户课程管理-选择课程 */
Route::group('admin/student/<userId>/choose', function () {
    // 获取课程列表--用于课程卡关联课程
    Route::get('courseList', '@getCourseList');
    // 获取课程分类
    Route::get('courseCategory/<pid>/list', '@getCourseCategory')->pattern(['pid' => '\d+']);
    // 获取课程分类
    Route::get('courseCategory/cascader', '@getCourseCategoryCascader');
    // 批量给学员添加课程
    Route::post('addCourse', '@addCourse');
})->prefix('\app\user\service\user\admin\Course')->middleware(['adminRoute'])->pattern(['userId' => '\d+']);